package com.neusoft.ysu.populationmanagement.mapper;

import com.neusoft.ysu.populationmanagement.entity.FloPop;
import com.neusoft.ysu.populationmanagement.entity.ImpPop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neusoft.ysu.populationmanagement.entity.ResPop;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2024-06-18
 */
@Mapper
public interface ImpPopMapper extends BaseMapper<ImpPop> {
    @Update("update imp_pop set " +
            "persontype_id=#{persontypeId}," +
            "undercontrol_id=#{undercontrolId}," +
            "personnum=#{personnum}," +
            "is_delete=#{isDelete} " +
            "where pop_id=#{popId} AND is_delete=0")
    int updateByPopId(ImpPop impPop);
    @Select("select * from imp_pop where pop_id=#{pop_id} AND is_delete=0")
    List<ImpPop> selectByPopId(Long pop_id);
    @Select("select * from imp_pop where pop_id=#{pop_id} AND is_delete=2")
    List<ImpPop> selectUncheckByPopId(Long pop_id);
    @Update("update imp_pop set " +
            "persontype_id=#{persontypeId}," +
            "undercontrol_id=#{undercontrolId}," +
            "personnum=#{personnum}," +
            "is_delete=#{isDelete} " +
            "where pop_id=#{popId} AND is_delete=2")
    int updateUncheckByPopId(ImpPop impPop);
    @Update("update imp_pop set " +
            "persontype_id=#{persontypeId}," +
            "undercontrol_id=#{undercontrolId}," +
            "personnum=#{personnum}," +
            "is_delete=#{isDelete} " +
            "where pop_id=#{popId} AND is_delete=3")
    int updateUnfinalByPopId(ImpPop impPop);

    int insertImpPopList(@Param("list") List<ImpPop> impPopList);

    @Select("select * from imp_pop where pop_id=#{pop_id} AND is_delete=3")
    List<ImpPop> selectUnfinalByPopId(Long popId);

    @Update("update imp_pop set " +
            "is_delete=#{isDelete} " +
            "where pop_id=#{popId}")
    int deleteByPopId(ImpPop impPop);
}
